<template>
	<view>
		<view class="empty" v-if='emptyData'>
			<u-empty mode="data">
			</u-empty>
		</view>
		<view class="con" v-else>
			<view class="item" v-for="(item,index) in index_list" :key="index" @click="btn_click_dia(item.id)">
				<view class="left">
					<image src="../../static/banner.png" mode=""></image>
				</view>
				<view class="right">
					<view class="title">{{item.title}}</view>
					<view class="desc">{{item.room}}室{{item.office}}厅/{{item.area}}m²/{{item.community_name}}</view>
					<view class="money">
						<view class="mon">{{item.money}}万 </view>
						<view class="text">{{item.art}}元/平</view>
					</view>
					<view class="address">
						<view class="icon">
							<u-icon name="map"></u-icon>
						</view>
						<view class="text">
							{{item.address}}
						</view>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				cardList: [{
						id: 1,
						icon: '/static/home/bgf.png',
						title: '出售'
					},
					{
						id: 2,
						icon: '/static/fabu/chuzu.png',
						title: '出租'
					}
				],
				house_type: 1,
				limit: 10,
				page: 1,
				emptyData: false,
				index_list: [],
				house_title: '',
				searchContent: ''
			};
		},
		methods: {
			btn_click(index) {
				if (index == 0) {
					this.house_type = 1;
				} else {
					this.house_type = 2;

				}
				this.index_list = [];
				this.loadData()
			},
			async loadData() {
				let that = this;
				that.http("applet_house_Index_get_search", {
					search: that.searchContent
				}).then(res => {
					if (res.ec == 200) {
						if (res.data.lists.length == 0) {
							this.emptyData = true;
						} else {
							this.emptyData = false;
						}
						res.data.lists.forEach(function(item, index) {
							that.index_list.push(item)
						})
					}
				})
			},
			btn_click_dia(id) {
				uni.navigateTo({
					url: '/pages/detail/detail?id=' + id,

				})
			},
		},
		onLoad(option) {
			this.index_list = [];
			this.house_title = option.title
			this.searchContent = option.search
			this.loadData();

			uni.setNavigationBarTitle({
				title: "搜索"
			})
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		display: flex;
		background-color: #fff;
		width: 90%;
		height: 220rpx;
		margin: auto;
		margin-top: 28rpx;
		justify-content: space-around;
		align-items: center;
		border-radius: 20rpx;

		.card-box {
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			align-items: center;

			.icon-img {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
			}
		}

	}

	.con {
		display: flex;
		flex-direction: column;
		margin-top: 20rpx;

		.item {
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;
			padding-bottom: 10rpx;
			padding-top: 10rpx;
			border-bottom: 1rpx solid #f0f0f0;

			.left {
				width: 250rpx;
				height: 181rpx;
				overflow: hidden;
				margin: 0 20rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.right {
				display: flex;
				flex-direction: column;
				flex: 1;

				.title {
					font-size: 28rpx;
					font-weight: 600;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					width: 99%;
				}

				.desc {
					font-size: 26rpx;
					margin: 10rpx 0;
					max-width: 98%;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.money {
					display: flex;
					flex-direction: row;
					margin: 10rpx 0;

					.mon {
						font-size: 30rpx;
						color: #eb584e;
						font-weight: 600;
					}

					.text {
						font-weight: 24rpx;
						color: #959595;
						margin-left: 10rpx;
					}
				}

				.address {
					display: flex;
					flex-direction: row;
					font-size: 24rpx;
					color: #959595;
				}
			}
		}
	}
</style>
